import Vue from 'vue'
import Vuex from 'vuex'


Vue.use(Vuex)

export default new Vuex.Store({
	
    //data
  state: {
	  
	  //个人信息
	  UserInfo:{
	  		  userid:"",
	  		  username:"",
	  		  gender:"",
	  		  age:{
				  type:Number
			  },
	  		  introduction:"",
	  		  province:"",
	  		  email:""
	  },
	  isLogin:false,  //登录状态
  },
  
   //methods
  mutations: {
	  changeUserInfo(state,value){
	  	  //v为传递值
	  	  state.UserInfo = value;
	  },
	  
	  initUserInfo(state){
		  state.UserInfo.userid="";
		  state.UserInfo.username="";
		  state.UserInfo.password="";
		  state.UserInfo.gender="";
		  state.UserInfo.age=new Number;
		  state.UserInfo.introduction="";
		  state.UserInfo.province="";
		  state.UserInfo.email="";
	  }
	  
  },
  
   //异步ajax方法
  actions: {
  },
  
    //模块
  modules: {
  },
  
  
  getters:{
	  //监听数据变化
	  
	  getStorage(state){
		  //获取本地存储的登录信息
		  if(!state.token){
			  //eslint-disable-next-line no-undef
			  state.token = JSON.parse(localStorage.getItem(Key));
		  }
		  return state.token;
	  }
  }
})
